package com.sfh.cpc.home.fragment;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sfh.cpc.BaseSwipeRefreshMoreLayoutFragment;
import com.sfh.cpc.com.entity.ENote;
import com.sfh.cpc.com.entity.RspPage;
import com.sfh.cpc.home.adapter.NoteAdapter;
import com.sfh.cpc.home.model.NoticeModel;
import com.sfh.cpc.note.NoteActivity;
import com.sfh.lib.mvvm.annotation.LiveDataMatch;

/**
 * 功能描述: 最新话题
 *
 * @author SunFeihu 孙飞虎
 * @date 2018/8/6
 */
public class NoteNewPageFragment extends BaseSwipeRefreshMoreLayoutFragment<NoticeModel> {

    public static NoteNewPageFragment newFragment() {
        return new NoteNewPageFragment();
    }

    @Override
    public String getName() {
        return "最新";
    }


    @Override
    public BaseQuickAdapter getAdapter() {
        return new NoteAdapter();
    }

    @Override
    public void loadPage(int nowPage) {
        getViewModel().pageNewNote(nowPage);
    }

    @LiveDataMatch
    public void onPageSuccess(RspPage<ENote> data) {
        super.onPageData(data);
    }

    @Override
    public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
        ENote note = (ENote) adapter.getItem(position);
        NoteActivity.startUI(getContext(), note);
    }


}
